<?php
/**
 *
 *
 */

include_once('../Model/User.php');
include_once('../Model/UserDetail.php');
//include_once('../Model/m_SignUp.php');

if(isset($_POST)) {

	// Get data from Sign-up form.
	$firstName = $_POST['txtFirstName'];
	$lastName = $_POST['txtLastName'];
	$userName = $_POST['txtUserName'];
	$passWord = $_POST['txtPassWord'];
	$gender = $_POST['slGender'];
	$email = $_POST['txtEmail'];
	$tel = $_POST['txtTel'];

	// Birthday.
	$birth = $_POST['txtDay'];

	$user = new User();
	$userDetail = new UserDetail();

	// Set userName, passWord of User Object
	$user->setUserName($userName);
	$user->setPassWord($passWord);

	$idUser = $user->insert($user);

	// Set data into userDetail
	$userDetail->setUserID($idUser);
	$userDetail->setFirstName($firstName);
	$userDetail->setLastName($lastName);
	$userDetail->setGender($gender);
	$userDetail->setEmail($email);
	$userDetail->setTel($tel);
	$userDetail->setBirthDay($birth);

	// Insert user's detail into database
	if($userDetail->insert($userDetail)) {
		header('location:../View/v_SignIn.php?succ');
	}
}
?>